既然我們上傳成功了,那麼接著就是要觀察我們的結果啦!!
第一步:打開CMD進入資料夾登入heroku :Heroku login
接著輸入heroku logs -t
第二步:回到LineDeveloper在Webhook那邊按下Verify,第一次可能會顯示聯繫時間過長,再重新按一次出現Success即可,或著對你的機器人傳一句話,最後回到Cmd觀察結果
或著開啟Heroku 點選view logs
在機器人上隨意輸入文字
下面為LOG小解釋我們可以利用之前的print(body) 來DEBUG
2021-09-10T13:01:12.143737(時間)+00:00(時區) herokuweb.1
#開機過程
2021-09-10T13:01:12.143737+00:00 heroku[web.1]: Unidling
2021-09-10T13:01:12.191184+00:00 heroku[web.1]: State changed from down to starting
2021-09-10T13:01:15.215188+00:00 heroku[web.1]: Starting process with command `python app.py`
2021-09-10T13:01:17.890501+00:00 app[web.1]: * Serving Flask app 'app' (lazy loading)
2021-09-10T13:01:17.890523+00:00 app[web.1]: * Environment: production
2021-09-10T13:01:17.890524+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2021-09-10T13:01:17.890542+00:00 app[web.1]: Use a production WSGI server instead.
2021-09-10T13:01:17.890562+00:00 app[web.1]: * Debug mode: off
2021-09-10T13:01:17.891354+00:00 app[web.1]: * Running on all addresses.
2021-09-10T13:01:17.891355+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2021-09-10T13:01:17.891443+00:00 app[web.1]: * Running on http://172.17.235.246:3934/ (Press CTRL+C to quit)
2021-09-10T13:01:18.910050+00:00 heroku[web.1]: State changed from starting to up
#我們在程式碼中打的BODY
2021-09-10T13:01:20.259516+00:00 app[web.1]: {"destination":"Ufdb60144d9df5192d6b70e710f80fc98",
#資料類型及訊息等細項
"events":[{"type":
"message","message":{"type":"text","id":"14723942825210","text":"123"},
#時間
"timestamp":1631278871264,
"source":{"type":"user","userId":"U27a3a4b39f0eb83d470fb1e80a55f18c(使用者ID之後可以用於@之類等動作)"},
"replyToken":"8732dfb931314c7da13e179245c7d5dd","mode":"active"}]}
#顯示訊息格式及過程
2021-09-10T13:01:20.509499+00:00 app[web.1]: 10.1.29.43 - - [10/Sep/2021 13:01:20] "POST /callback HTTP/1.1" 200 -
2021-09-10T13:01:20.511085+00:00 heroku[router]: at=info method=POST path="/callback" host=juctest.herokuapp.com request_id=b7d7973e-3b68-4e50-acb2-4294cfe008b9 fwd="147.92.149.166" dyno=web.1 connect=0ms service=251ms status=200 bytes=154 protocol=https
2021-09-10T13:01:30.216586+00:00 app[web.1]: {"destination":"Ufdb60144d9df5192d6b70e710f80fc98","events":[{"type":"message","message":{"type":"text","id":"14723944538162","text":"ABC"},"timestamp":1631278889400,"source":{"type":"user","userId":"U27a3a4b39f0eb83d470fb1e80a55f18c"},"replyToken":"0a8b77ba7f1c4783a750b6117d438038","mode":"active"}]}
2021-09-10T13:01:30.535723+00:00 heroku[router]: at=info method=POST path="/callback" host=juctest.herokuapp.com request_id=5814d2d5-3a1a-4119-856c-3d75d6cd9f75 fwd="147.92.149.166" dyno=web.1 connect=0ms service=321ms status=200 bytes=154 protocol=https
2021-09-10T13:01:30.536112+00:00 app[web.1]: 10.1.87.69 - - [10/Sep/2021 13:01:30] "POST /callback HTTP/1.1" 200 -
參考資料:第 11 天:LINE BOT SDK:應用程式編程介面|從LINE BOT到資料視覺化:賴田捕手 系列